package cn.new7as.cas5s.ui.record;


import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.hjq.http.EasyHttp;
import com.hjq.http.listener.OnHttpListener;

import cn.new7as.cas5s.ui.slideshow.BaseActivity;
import cn.new7as.cas5s.databinding.ActivityOrdersBinding;
import cn.new7as.cas5s.ui.easy.netapi.HttpData;
import cn.new7as.cas5s.ui.easy.netapi.OrderApi;


public class SelectOrdersActivity extends BaseActivity {


    private ActivityOrdersBinding binding;

    @SuppressLint("MissingPermission")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityOrdersBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        setop("Select an Order");
        initV();

    }

    @Override
    public void initV() {
        super.initV();
        show();
        getorder();
    }


    public void setBack(String da) {
        Intent intent = new Intent();
        intent.putExtra("tno", da);
        setResult(RESULT_OK, intent);
        finish();
    }


    private void getorder() {
        EasyHttp.post(this)
                .api(new OrderApi(getunique(), 0)).request(new OnHttpListener<HttpData<OrderApi.OrderData>>() {

                    @Override
                    public void onHttpSuccess(@NonNull HttpData<OrderApi.OrderData> result) {

                        hide();
                        binding.ordersgride.setAdapter(new SelectOrdersadapter(result.getResult().repaymentRecords, SelectOrdersActivity.this));
                    }

                    @Override
                    public void onHttpFail(@NonNull Throwable throwable) {
                        deal(throwable);
                    }
                });
    }

}